package com.daedalus.File.NotatMaksimale;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Formatter;
import java.util.Scanner;


public class NotaMesatare {

	public static void main(String[] args) {

		Scanner s=new Scanner(System.in);		//per te lexuar emrin e skedarit
		String skedari;
		Scanner in;				// per te lexuar nga skedari
		Formatter out;			// per te shkruar ne filin e ri
				
		System.out.print("Jep emrin e skedarit: ");
		skedari = s.next();		// ruaj emrin e skedarit input

		try {		// provoj te hap skedarin per te lexuar
			in=new Scanner(new File(skedari));
            out=new Formatter("notaMes.txt");
        } catch (FileNotFoundException e1) {
			System.out.print("File nuk u gjet");
			return;
		}
		double notaMesatareMax=0;
        double notaMesatareMin=11;
        String StudentiMire="", StudentiDobet="";
		while(in.hasNext()){		// per sa kohe ka akoma per te lexuar
			String stud=in.next();		//lexoj emrin e studentit
			int shumaNotave=0;

			for(int i=0; i<5; i++){		// lexoj 5 notat
				shumaNotave+=in.nextInt();
            }
            double notaMes=(double)shumaNotave/5;
			if (notaMes>notaMesatareMax){
                StudentiMire=stud;
                notaMesatareMax=notaMes;
            }
            if (notaMes<notaMesatareMin){
                StudentiDobet=stud;
                notaMesatareMin=notaMes;
            }
		}

        out.format("Studenti me mesatare me te larte: %s Mesatarja: %.2f",StudentiMire,notaMesatareMax);
        out.format("\nStudenti me mesatare me te dobet: %s Mesatarja: %.2f",StudentiDobet,notaMesatareMin);


        in.close();
		out.close();		
	}
}
